﻿@model IMS_FinanceRecv
@{
	ViewBag.Title = "查看收款单信息";
}
@section header{
}
@section quickmenu{
	<td style="padding-right: 0px; padding-left: 10px;">
		<span style="cursor: pointer;" title="新增..." @@click="pageAdd">
			<i class="icon-plus icon-2x pull-left icon-border crm-bu-style"></i>
		</span>
	</td>
	<td style="padding-right: 0px; padding-left: 10px;">
		<span style="cursor: pointer;" title="返回..." @@click="pageBack">
			<i class="icon-reply icon-2x pull-left icon-border crm-bu-style"></i>
		</span>
	</td>
}

<table style="border:0;margin:0;border-spacing:0;width:100%;padding:0 15px 10px 15px;overflow:auto;table-layout:fixed;">
	<tbody>
		<tr>
			<td class="detail-left-td">
				<div class="detail-panel-div">
					<div class="detail-inner">
						<div class="detail-name-div" @@click="resetView" title="@Model.SNo">
							@Model.SNo
						</div>
					</div>
					<div class="detail-heading">
						相关记录
					</div>
					<div class="detail-inner detail-related">
						<div class="detail-list-div" :class="{'detail-list-div-on':viewid==ritem.id}" @@click="changeView(ritem.id)" v-for="(ritem) in related">
							{{ritem.name}}<span class="detail-list-count" v-if="ritem.count>0">{{ritem.count}}</span>
						</div>
					</div>
					<div class="detail-exit">&nbsp;</div>
				</div>
			</td>
			<td style="vertical-align:top;" class="detail-content-td">
				<div style="width:100%;margin:0;padding:0;" v-show="viewid=='main'">
					<table style="width:100%;">
						<tr>
							<td style="vertical-align:top;">
								<div class="detail-panel-div" style="position:relative;">
									@*<div style="position:absolute;right:40%;top:40px;">
											<img src="~/img/yinzhang1.svg" style="width:80px;" />
										</div>*@
									<table border="0" cellspacing="0" cellpadding="5" style="height:42px;width:100%;">
										<tbody>
											<tr style="height: 38px;">
												<td>
													&nbsp;
													<button class="pure-button pure-button-edit" @@click="pageEdit">
														<i class="icon-edit"></i>&nbsp;编辑
													</button>
													@*&nbsp;
														<button class="pure-button pure-button-approve" @@click="pageAudit">
															<i class="icon-shenhe"></i>&nbsp;审核
														</button>*@
													&nbsp;
													<button class="pure-button pure-button-cancel" @@click="pageBack">
														<i class="icon-reply"></i>&nbsp;返回
													</button>
												</td>
												<td align="right">
													@*<button class="pure-button pure-button-secondary" @@click="pageCopy">
															<i class="icon-copy"></i>&nbsp;复制
														</button>
														&nbsp;*@
													@*<button class="pure-button pure-button-inverse" @@click="pageMerge">
															<i class="icon-copy-alt"></i>&nbsp;合并产品
														</button>
														&nbsp;*@
													<button class="pure-button pure-button-danger" @@click='pageDelete'>
														<i class="icon-trash"></i>&nbsp;删除
													</button>
													&nbsp;
												</td>
											</tr>
											<tr class="detail-content-heading" style="height: 28px; cursor: pointer;user-select: none;" onclick="detailBodyToggle(this);">
												<td colspan="2">
													<b>&nbsp;基本信息&nbsp;</b>
													<span style="cursor: pointer; height: 30px; width: 30px;">
														<i class="icon-angle-up"></i>
													</span>
												</td>
											</tr>
											<tr>
												<td colspan="2">
													<table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
														<tr style="height: 25px">
															<td class="detail-content-label" width="20%">
																往来单位名称
															</td>
															<td class="detail-content-info" width="30%">
																&nbsp;<a href="@(Url.Action("ViewDetail", "IMS_Partner", new { id = Model.PartnerID }))" target="_blank">@Model.PartnerName</a>
															</td>
															<td class="detail-content-label" width="20%">
																收款单编号
															</td>
															<td class="detail-content-info fontBold" width="30%">
																&nbsp;@Model.SNo
															</td>
														</tr>
														<tr style="height: 25px">
															<td class="detail-content-label">
																收款日期
															</td>
															<td class="detail-content-info">
																&nbsp;@Model.RecvDate.ToString("yyyy-MM-dd")
															</td>
															<td class="detail-content-label">
																是否开发票
															</td>
															<td class="detail-content-info">
																&nbsp;@{if (Model.Invoice)
																	{
																		<i class='icon-check'></i>
																	}
																	else
																	{
																		<i class='icon-remove'></i>
																	}
																}
															</td>
														</tr>
														<tr style="height: 25px">
															<td class="detail-content-label">
																创建时间
															</td>
															<td class="detail-content-info">
																&nbsp;@Model.AddDate.ToString("yyyy-MM-dd HH:mm:ss")
															</td>
															<td class="detail-content-label">
																创建人
															</td>
															<td class="detail-content-info">
																&nbsp;@Model.AddManName
															</td>
														</tr>
														<tr style="height: 45px">
															<td class="detail-content-label">
																备注
															</td>
															<td class="detail-content-info" colspan="3">
																&nbsp;@(Model.Comment)
															</td>
														</tr>
													</table>
												</td>
											</tr>
											<tr class="detail-content-heading" style="height: 28px; cursor: pointer;user-select: none;" onclick="detailBodyToggle(this);">
												<td colspan="2">
													<b>&nbsp;收款明细&nbsp;</b>
													<span style="cursor: pointer; height: 30px; width: 30px;">
														<i class="icon-angle-up"></i>
													</span>
												</td>
											</tr>
											<tr>
												<td colspan="2">
													<table class="edit-table padding3" border="0" cellpadding="3" cellspacing="1" style="width:100%;">
														<tbody>
															<tr class="windLayerHead" height="25px">
																<td style="text-align:center;">
																	<b>序号</b>
																</td>
																<td style="text-align: center;">
																	<b>应收款单</b>
																</td>
																<td style="text-align: center;">
																	<b>相关业务类型</b>
																</td>
																<td style="text-align: center;">
																	<b>相关业务单号</b>
																</td>
																<td style="text-align: center;">
																	<b>期次</b>
																</td>
																<td style="text-align:center;">
																	<b>应收日期</b>
																</td>
																<td style="text-align:right;">
																	<b>应收金额</b>
																</td>
																<td style="text-align:right;">
																	<b>已收金额</b>
																</td>
																<td style="text-align:right;"><b>本次收款</b></td>
																<td style="text-align:right;"><b>剩余金额</b></td>
															</tr>
														</tbody>
														<tr v-for="(ditem,didx) in model.Details">
															<td style="text-align: center;">{{didx+1}}</td>
															<td style="">
																{{ditem.DueRecv.SNo}}
															</td>
															<td style="text-align: center;">
																{{ditem.DueRecv.BuzType | formatBuzType}}
															</td>
															<td style="text-align: center;">
																{{ditem.DueRecv.BuzSNo}}
															</td>
															<td style="text-align: center;">
																{{ditem.DueRecv.Stage}}
															</td>
															<td style="text-align:center;">
																{{ditem.DueRecv.DueDate | formatDate("yyyy-MM-dd")}}
															</td>
															<td style="text-align:right;">
																{{ditem.DueRecv.TotalRecvDue.toFixed(2)}}
															</td>
															<td style="text-align:right;">
																{{ditem.DueRecv.TotalRecved.toFixed(2)}}
															</td>
															<td style="text-align:right;">
																{{ditem.Recved.toFixed(2)}}
															</td>
															<td style="text-align:right;">
																{{ditem.DueRecv.TotalRecvLeft.toFixed(2)}}
															</td>
														</tr>
														<tr>
															<td colspan="8" style="text-align:right;border-bottom:none;" class="detail-content-label">合计</td>
															<td style="font-weight:bold;text-align:right;">￥@(Model.TotalRecv)</td>
															<td></td>
														</tr>
													</table>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
						</tr>
					</table>
				</div>
				<sys-attachment relatedid="@Model.ID" ref="sys_attachment" :visible="viewid=='sys_attachment'" listurl="@(Url.Action("Search", "Sys_Attachment"))" counturl="@(Url.Action("Count", "Sys_Attachment"))" @@change="relatedChange('sys_attachment',$event)" callback="relatedUploadCallback" deleteurl="@(Url.Action("Delete", "Sys_Attachment"))" uploadurl="@(Url.Action("Upload", "Sys"))" tbl="@((int)ST.Buz.Base.Enums.TableCode.IMS_FinanceRecv)"></sys-attachment>
			</td>
		</tr>
	</tbody>
</table>
@section footer{
	<script src="~/js/related/sys_attachment.js" asp-append-version="true"></script>
	@*日期必须开始*@
	<script src="~/lib/laydate/laydate.js" asp-append-version="true"></script>
	@*日期必须结束*@
	@*验证开始*@
	<script src="~/lib/validationEngine/jquery.validationEngine.min.js" asp-append-version="true"></script>
	<script src="~/lib/validationEngine/jquery.validationEngine-zh_CN.js" asp-append-version="true"></script>
	<link href="~/lib/validationEngine/validationEngine.jquery.css" rel="stylesheet" asp-append-version="true" />
	@*验证结束*@
	@*列表相关开始*@
	<script type="text/javascript">
		var pageEnumData = {
			state:@(Json.Serialize(ViewBag.StateOptions)),
			buztype:@(Json.Serialize(ViewBag.BuzTypeOptions)),
			sharetype:@(Json.Serialize(ViewBag.ShareTypeOptions)),
		};
		var modelJson=@(Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model,new Newtonsoft.Json.JsonSerializerSettings()
				   {
				   DateFormatString = "yyyy-MM-dd HH:mm:ss"
					})));
		var modelData = $.extend(modelJson, {
		});
		var pageData = {
			hideBreadcrumb: false,
			serviceCode: '@(ViewBag.ServiceCode)',
			global: globalData,
			viewid: 'main',
			related: @(Json.Serialize(ViewBag.RelatedModules)),
			model: modelData
		};

		var pageApp = new Vue({
			el: '#app',
			data: pageData,
			created: function () {
			},
			mounted: function () {
				var _this = this;
				this.related.forEach(function (item) {
					_this.$refs[item.id] && _this.$refs[item.id].count();
				});
			},
			methods: {
				pageBack: function() {
					//history.go(-1);
					//history.back();
					if (document.referrer.indexOf('@(Url.Action("Add", "FinanceRecv"))') < 0 &&
						document.referrer.indexOf('@(Url.Action("Edit", "FinanceRecv", new { id = "" }))') < 0) {
						history.back();
					} else {
						location.href = '@(Url.Action("List", "FinanceRecv"))?nc=' + new Date().getTime();
					}
				},
				pageAdd: function() {
					location.href = '@(Url.Action("Add", "FinanceRecv"))?nc=' + new Date().getTime();
				},
				pageEdit: function() {
					location.href = '@(Url.Action("Edit", "FinanceRecv",new {id=Model.ID }))?nc=' + new Date().getTime();
				},
				pageDelete: function() {
					utils.confirm('确定要删除该条记录？', function () {
						utils.ajaxPost('@(Url.Action("Delete", "FinanceRecv"))', { id: @Model.ID }, function (resp) {
							utils.success("删除成功");
							location.href = '@(Url.Action("List", "FinanceRecv"))?nc=' + new Date().getTime();
						}, function (msg) {
							utils.alert(msg);
						});
					});
				},
				relatedChange: function (vid, e) {
					switch (e.action) {
						case "total":
							{
								this.related = this.related.map(function (item) {
									if (item.id == vid) {
										return Object.assign({}, item, { count: e.data });
									} else {
										return item;
									}
								});
							}
							break;
					}
				},
				changeView: function(vid) {
					this.viewid = vid;
					this.$refs[vid]&&this.$refs[vid].reload();
				},
				resetView: function() {
					this.viewid = 'main';
				}
			},
			computed: {
				currentM: function () {
					var currentM = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentM = this.global.modules[i];
								break;
							}
						}
					}
					return currentM;
				},
				currentS: function () {
					var currentS = null;
					var i;
					var j;
					for (i = 0; i < this.global.modules.length; i++) {
						for (j = 0; j < this.global.modules[i].Services.length; j++) {
							if (this.serviceCode == this.global.modules[i].Services[j].Code) {
								currentS = this.global.modules[i].Services[j];
								break;
							}
						}
					}
					return currentS;
				}
			},
			filters: {
				formatBuzType: function (val) {
					return utils.formatEnum(val, pageEnumData.buztype);
				},
				formatShareType: function (val) {
					return utils.formatEnum(val, pageEnumData.sharetype);
				}
			}
		});

		function detailBodyToggle(obj) {
			var $obj = $(obj);
			$obj.next('tr').toggle();
			$obj.find('i').toggleClass("icon-angle-up icon-angle-down");
		}

		function relatedUploadCallback(e) {
			layer.close(layer.index);
			console.log(e);
			pageApp.$refs.sys_attachment.reload();
		}
	</script>
	@*列表相关结束*@
	@*导出相关开始*@
	<script type="text/javascript">
		function exportAll() {
		}

		function exportCurrent() {
		}

		function exportSelected() {
		}
	</script>
	@*导出相关结束*@
}